import request from "@/utils/request";

//根据LevelId查询任务列表
export function getDrillTasksList(levelId) {
    return request({
        url: "/drill/levelTask/list/" + levelId,
        method: "get",
    });
}

/**
 * 演练计划指派任务接口
 * @param {*} data
 * @returns
 */
export function drillTaskSet(data) {
    return request({
        url: "/drill/levelTask",
        method: data.taskId == 0 ? "post" : "put",
        data: data,
    });
}

/**
 * 获取一二级演练任务列表
 * @param {*} param
 */
export function getDrillTaskList(userId, params) {
    return request({
        url: "/drill/levelTask/listByUserId/" + userId,
        method: "get",
        params: params,
    });
}

/**
 * 获取子任务列表
 * @param {*} parentId
 * @returns
 */
export function getChildTaskList(parentId) {
    return request({
        url: "/drill/levelTask/listByParentId/" + parentId,
        method: "get",
    });
}

/**
 * 二级任务下发
 * @param {*} taskId
 * @returns
 */
export function startDrillSonTask(taskId) {
    return request({
        url: "/drill/levelTask/openSecondTasks/" + taskId,
        method: "put",
    });
}

/**
 * 提交任务接口
 * @param {*} data
 * @returns
 */
export function handleSubmitTask(taskId, data) {
    return request({
        url: "/drill/levelTask/submitTask/" + taskId,
        method: "put",
        data: data,
    });
}

/**
 * 一级任务提交接口
 * @param {*} taskId
 * @returns
 */
export function completeTask(taskId) {
    return request({
        url: "/drill/levelTask/completeTask/" + taskId,
        method: "put",
    });
}

/**
 * 根据二级任务ID获取任务详情
 * @param {*} taskId
 * @returns
 */
export function getTaskInfo(taskId) {
    return request({
        url: "/drill/levelTask/getSonTask/" + taskId,
        method: "get",
    });
}
